package main.java.com.stylinlin.object;

import java.util.HashMap;
import java.util.HashSet;

/**
 * ObjectTest
 *
 * @author jonlin
 * @date 2020/6/30
 */
public class ObjectTest {
    public static void main(String[] args) throws Exception{
        // hashCode, equals
        ItemObject itemObject1 = new ItemObject();
        itemObject1.setStar(1);
        itemObject1.setSports("篮球");
        JonlinObject jonlinObject = new JonlinObject(1, "你好发的1达瓦哒哒哒你好发的11的1d", itemObject1);
        JonlinObject jonlinObject2 = new JonlinObject(1, "你好发的1达瓦哒哒哒你好发的11的1d", null);
        System.out.println("jonlinObject:" + jonlinObject.hashCode());
        System.out.println("jonlinObject2:" + jonlinObject2.hashCode());
        System.out.println(jonlinObject.equals(jonlinObject2));
        HashSet<JonlinObject> set = new HashSet<>();
        set.add(jonlinObject);
        set.add(jonlinObject2);
        System.out.println(set);

        System.out.println("****************************************************");
        // clone
        //性能比较：ms
        //dozer:721
        //commons-beanutils：229
        //cglib:133
        //serializable:687
        //orika:83
        //clone:8
        JonlinObject cloneObj = (JonlinObject)jonlinObject.clone();
        cloneObj.setId(3);
        cloneObj.getItemObject().setSports("互动的");
        // JonlinObject{id=3, name='你好发的1达瓦哒哒哒你好发的11的1d', itemObject=ItemObject{sports='互动的', star=1}}
        //JonlinObject{id=1, name='你好发的1达瓦哒哒哒你好发的11的1d', itemObject=ItemObject{sports='篮球', star=1}}
        System.out.println(cloneObj.toString());
        System.out.println(jonlinObject.toString());
    }
}
